package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.store.awk.bean.SubstanceListCardBean;
import o.azb;
import o.cgz;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.eqx;
import o.eqz;
import o.erq;
import o.evb;
import o.evf;
import o.ewm.c;
import o.ewm.d;
import o.ewm.e;
import o.ewm.j;
import o.fmw;

public class SubstanceListCardHeadItem extends AbstractSubstanceListItemCard implements eqz {
    private View ʻ;
    private TextView ʼ;
    private TextView ʽ;
    private TextView ˋ;
    private int ͺ = 1;
    private TextView ॱॱ;
    private ImageView ᐝ;

    public SubstanceListCardHeadItem(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ˋ = (TextView) view.findViewById(j.ʼˌ);
        this.ᐝ = (ImageView) view.findViewById(j.ʼˈ);
        this.ʼ = (TextView) view.findViewById(j.ʼᶥ);
        this.ʽ = (TextView) view.findViewById(j.ʼˑ);
        this.ॱॱ = (TextView) view.findViewById(j.ㆍʼ);
        this.ʻ = view.findViewById(j.ʼـ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        SubstanceListCardBean substanceListCardBean = (SubstanceListCardBean) cardBean;
        String str = (String) this.ᐝ.getTag();
        if (dof.ˋ(str) || !str.equals(substanceListCardBean.ʻᐝ())) {
            ˋ(this.ॱॱ, substanceListCardBean.ˋʻ());
            this.ᐝ.setTag(substanceListCardBean.ʻᐝ());
            ˊ(substanceListCardBean.ʿॱ());
            ˎ(substanceListCardBean.ॱﾞ());
            ᐝ(this.ʽ);
            Context ˋ = ContentManager.getInstant().getContext();
            int dimensionPixelSize = ˋ.getResources().getDimensionPixelSize(d.ᐝᐝ);
            int dimensionPixelSize2 = ˋ.getResources().getDimensionPixelSize(d.ॱʻ);
            this.ᐝ.setTag(substanceListCardBean.ʻᐝ());
            if (TextUtils.isEmpty(substanceListCardBean.ʽˋ())) {
                this.ˋ.setVisibility(8);
            } else {
                this.ˋ.setVisibility(0);
                this.ˋ.setText(substanceListCardBean.ʽˋ());
            }
            this.ʽ.setText(substanceListCardBean.ʽˊ());
            this.ʼ.setText(substanceListCardBean.ʾॱ());
            if (evf.ˊ(this.ᐝ)) {
                this.ᐝ.setImageDrawable((Drawable) fmw.ˏ(this.ᐝ.getContext(), e.ꜞ, "drawable"));
            } else {
                this.ᐝ.setImageResource(e.ꜞ);
            }
            if (this.ͺ != substanceListCardBean.ॱﾞ() || TextUtils.isEmpty(substanceListCardBean.ʿॱ())) {
                ᐝ();
                eqx.ˋ(dimensionPixelSize, dimensionPixelSize2, this.ᐝ, substanceListCardBean.ʻᐝ(), "image_default_icon");
                return;
            }
            eqx.ˏ(dimensionPixelSize, dimensionPixelSize2, this.ᐝ, substanceListCardBean.ʻᐝ(), "image_default_icon", this, true);
        } else if (Logger.ˎ()) {
            Logger.ˏ("SubstanceListCardHeadItem", "cardInfoBean.getBannerUrl_() = " + substanceListCardBean.ʻᐝ());
        }
    }

    public void ॱ(Bitmap bitmap) {
        if (bitmap == null || VERSION.SDK_INT <= 27 || this.ͺ != ˋ() || TextUtils.isEmpty(ˊ()) || evf.ˊ(this.ʽ)) {
            ᐝ();
            return;
        }
        try {
            this.ʻ.setBackground(new BitmapDrawable(this.ʽ.getResources(), evb.ˏ(Bitmap.createBitmap(bitmap, 0, (bitmap.getHeight() * 3) / 4, bitmap.getWidth(), bitmap.getHeight() / 4), 125, 15)));
            boolean ˏ = erq.ˏ(Color.parseColor(ˊ()));
            int i = -16777216;
            this.ʽ.setAlpha(azb.ˋ(this.ʼॱ, d.ߺ));
            if (ˏ) {
                i = -1;
                this.ʽ.setAlpha(azb.ˋ(this.ʼॱ, d.ॱʿ));
            }
            this.ʼ.setTextColor(i);
            this.ʽ.setTextColor(i);
        } catch (Exception e) {
            ᐝ();
            Logger.e("SubstanceListCardHeadItem", e.toString());
        }
    }

    private void ᐝ() {
        Resources resources = this.ʼॱ.getResources();
        this.ʻ.setBackgroundColor(resources.getColor(c.ˋॱ));
        this.ʼ.setTextColor(resources.getColor(c.ˏॱ));
        this.ʽ.setTextColor(resources.getColor(c.ॱˊ));
    }
}
